package com.project.controller;

import com.project.bean.InfoBean;
import com.project.bean.UserBean;
import com.project.service.IInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("info")
public class InfoController {
    @Autowired
    private IInfoService service;
    @RequestMapping("add")
    public String add(InfoBean info, HttpServletRequest req){
        //先从session中，得到登陆用户
        UserBean user =(UserBean) req.getSession().getAttribute("loginUser");
        info.setUserId(user.getId());
        service.add(info);
        return "ok";
    }
}
